package com.codeplex.tdmg4mc;

import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.Item.ToolMaterial;
import net.minecraft.item.ItemArmor.ArmorMaterial;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.config.Configuration;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.registry.EntityRegistry;
import cpw.mods.fml.common.registry.GameRegistry;

@Mod(modid=TDMG.MODID, name=TDMG.NAME, version=TDMG.VERSION, dependencies="required-after:Forge@[10.12.1.1060,);required-after:RenderPlayerAPI@[1.2,)")
public class TDMG
{
	public static final String NAME = "Three-Dimensional Maneuver Gear";
	public static final String MODID = "tdmg";
	public static final String VERSION = "1.1.1.1";
	@Instance(MODID)
	public static TDMG instance;
	private static Configuration config;
	@SidedProxy(clientSide="com.codeplex.tdmg4mc.TDMGClientProxy", serverSide="com.codeplex.tdmg4mc.TDMGServerProxy")
	public static TDMGCommonProxy proxy;
	public static final String KEYS="keys";
	public static final String LEGS_TAG="tdmg_legs";
	public static final String FUEL_TAG="tdmg_fuel";
	public static final String DUAL_SWORD_TAG="tdmg_dualsword";
	public static final String BLADE_TAG="tdmg_blade";
	public static Item legs;
	public static Item fuel;
	public static Item dualSword;
	public static Item blade;
	public static boolean isClient;

	@EventHandler
	public void preInit(FMLPreInitializationEvent event)
	{
		instance=this;
		config=proxy.getConfig();
	    config.load();
		int renderId=proxy.addArmor(MODID);
		
		legs=new ItemGear(ArmorMaterial.IRON, renderId, 2).setUnlocalizedName(LEGS_TAG).setTextureName("tdmg:legs");
		GameRegistry.addRecipe(new ItemStack(legs, 1), "A A", "S S", "DLD", 'A', Items.arrow, 'S', Items.string, 'D', Blocks.dispenser, 'L', Items.leather_leggings);
		GameRegistry.registerItem(legs, LEGS_TAG, MODID);

		fuel=new Item().setUnlocalizedName(FUEL_TAG).setCreativeTab(CreativeTabs.tabCombat)
				.setMaxDamage(1200).setMaxStackSize(1).setNoRepair().setTextureName("tdmg:fuel");
		GameRegistry.addSmelting(Items.water_bucket, new ItemStack(fuel, 1), 0.1f);
		GameRegistry.registerItem(fuel,  FUEL_TAG, MODID);

		blade=new Item().setMaxStackSize(16).setUnlocalizedName(BLADE_TAG)
				.setCreativeTab(CreativeTabs.tabCombat).setTextureName("tdmg:blade");
		GameRegistry.addRecipe(new ItemStack(blade, 1), "  I", " I ", "I  ", 'I', Items.iron_ingot);
		GameRegistry.registerItem(blade, BLADE_TAG, MODID);

		dualSword=new ItemDualSword(ToolMaterial.IRON).setUnlocalizedName(DUAL_SWORD_TAG);
		GameRegistry.addRecipe(new ItemStack(dualSword, 1), "B B", "I I", "SSS", 'B', blade, 'I', Items.iron_ingot, 'S', Items.string);
		GameRegistry.registerItem(dualSword, DUAL_SWORD_TAG, MODID);

		EntityRegistry.registerModEntity(EntityGearHook.class, "TDMG Hook", EntityRegistry.findGlobalUniqueEntityId(), this, 0, 1, true);
		MinecraftForge.EVENT_BUS.register(new TDMGEventHandler());
		proxy.init(config);
		config.save();
	}
}
